package com.home.duy.GUI;


import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JInternalFrame;

import com.home.Common.Common;
import com.home.Common.Resources_Duy;
import com.home.Entity.CTQuyenSuDung;
import com.home.Entity.QuyenSuDung;
import com.home.Entity.TaiKhoan;
import com.home.duy.code.DAO.CTQuyenSuDungDAO;
import com.home.duy.code.DAO.QuyenSuDungDAO;
import com.home.duy.code.DAO.TaiKhoanDAO;

import java.awt.Checkbox;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JCheckBox;
import javax.swing.border.Border;
import javax.swing.border.MatteBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.util.List;
import java.util.Vector;

import javax.swing.JTabbedPane;

import org.apache.commons.codec.net.BCodec;

import java.awt.GridBagLayout;

public class CapQuyen extends JInternalFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Vector<JCheckBox> checkBoxs;
	private TaiKhoan tkSecleted = null;

	private ParentFrame parent;

	private JPanel jContentPane = null;

	private JPanel panelDSTK = null;

	private JScrollPane scrollPaneDSTK = null;

	private JList listTK = null;

	private JPanel panelQuyen = null;

	private JTabbedPane tabbedPane = null;

	private JPanel panel1 = null;

	private JPanel panel2 = null;

	private JPanel panel3 = null;

	private JPanel panelTTQ = null;

	private JLabel jLabel = null;

	private JCheckBox checkBoxTT = null;

	private JCheckBox checkBoxKV = null;

	private JCheckBox checkBoxBan = null;

	private JCheckBox checkBoxThietBi = null;

	private JPanel panelNV = null;

	private JCheckBox checkBoxTTNV = null;

	private JCheckBox checkBoxPhanCong = null;

	private JCheckBox checkBoxBanDKCL = null;

	private JCheckBox checkBoxQLCL = null;

	private JLabel jLabel1 = null;

	private JCheckBox checkBoxChamCong = null;

	private JCheckBox checkBoxTinhLuong = null;

	private JCheckBox checkBoxThuongPhat = null;

	private JPanel panelPQ = null;

	private JCheckBox checkBoxTTTK = null;

	private JCheckBox checkBoxCQTK = null;

	private JLabel jLabel2 = null;

	private JPanel panelNghiepVu = null;

	private JCheckBox checkBoxBanHang = null;

	private JCheckBox checkBoxTimBan = null;

	private JCheckBox checkBoxCTKM = null;

	private JLabel jLabel3 = null;

	private JPanel panelThucDon = null;

	private JCheckBox checkBoxTTTD = null;

	private JCheckBox checkBoxPhaChe = null;

	private JLabel jLabel4 = null;

	private JPanel panelBCTK = null;

	private JCheckBox checkBoxChiPhi = null;

	private JCheckBox checkBoxSoLuong = null;

	private JCheckBox checkBoxDoanhThu = null;

	private JCheckBox checkBoxQuyTM = null;

	private JLabel jLabel5 = null;

	private JPanel panelNVL = null;

	private JCheckBox checkBoxTTNVL = null;

	private JCheckBox checkBoxKiemKho = null;

	private JLabel jLabel6 = null;
	private JPanel panelThongKe = null;
	private JLabel jLabel7 = null;
	private JLabel lblTongQuyenHT = null;
	private JPanel jPanel = null;
	private JLabel jLabel8 = null;
	private JLabel lblTKQLTTQ = null;
	private JLabel jLabel9 = null;
	private JLabel lblTKQLNVL = null;
	private JLabel jLabel10 = null;
	private JLabel lblTKBCTK = null;
	private JPanel jPanel1 = null;
	private JLabel jLabel11 = null;
	private JLabel lblTongCong = null;

	/**
	 * This is the xxx default constructor
	 */
	public CapQuyen(ParentFrame parent) {
		super();
		this.parent = parent;
		checkBoxs = new Vector<JCheckBox>();
		initialize();
		setThongKe();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(800, 540);
		this.setContentPane(getJContentPane());
		this.setTitle(Resources_Duy.TITLE_MENU_ITEM_CAPQUYENTK);
		this.setClosable(true);
		this.setIconifiable(true);
	}

	// ========================= PROCESS METHOD =====================

	@SuppressWarnings("unchecked")
	private Vector<TaiKhoan> getAllTaiKhoan() {
		Vector<TaiKhoan> tks = new Vector<TaiKhoan>();
		try {

			TaiKhoanDAO tkDao = new TaiKhoanDAO();
			List<TaiKhoan> list = tkDao.findAll(TaiKhoan.class);
			for (TaiKhoan tk : list) {
				if (!tk.isLoai())
					tks.add(tk);
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage(), "Lỗi",
					JOptionPane.ERROR_MESSAGE);
		}

		return tks;
	}

	private void processSelectItemList() {
		try {
			if (listTK.getSelectedValue() != null) {
				setThongKe();
				tkSecleted = (TaiKhoan) listTK.getSelectedValue();
				QuyenSuDungDAO qsdDao = new QuyenSuDungDAO();
				CTQuyenSuDungDAO ctQsdDao = new CTQuyenSuDungDAO();
				for (JCheckBox cb : checkBoxs) {
					QuyenSuDung q = (QuyenSuDung) qsdDao.findByPk(
							QuyenSuDung.class, Long.parseLong(cb.getName()));
					CTQuyenSuDung ctQsd = (CTQuyenSuDung) ctQsdDao
							.findByTKandQSD(tkSecleted.getMaSo(), q.getMaSo());
					if (ctQsd != null) {
						cb.setSelected(true);
					} else {
						cb.setSelected(false);
					}
				}
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage(), "Lỗi",
					JOptionPane.ERROR_MESSAGE);
		}
	}

	private void processCheckBoxStateChange(JCheckBox cb) {
		try {
			QuyenSuDungDAO qsdDao = new QuyenSuDungDAO();
			CTQuyenSuDungDAO ctQsdDao = new CTQuyenSuDungDAO();
			QuyenSuDung qsd = (QuyenSuDung) qsdDao.findByPk(QuyenSuDung.class,
					Long.parseLong(cb.getName()));
			if (cb.isSelected()) {
				CTQuyenSuDung ctQsd = new CTQuyenSuDung();
				ctQsd.setMaSo(Common.getID());
				ctQsd.setQuyenSuDung(qsd);
				ctQsd.setTaiKhoan(tkSecleted);
				ctQsdDao.saveOrUpdate(ctQsd);
			} else {
				CTQuyenSuDung ctQsd = (CTQuyenSuDung) ctQsdDao.findByTKandQSD(
						tkSecleted.getMaSo(), qsd.getMaSo());
				ctQsdDao.delete(ctQsd);
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage(), "Lỗi",
					JOptionPane.ERROR_MESSAGE);
		}
	}
	
	private int getTongSoQuyenCuaHT()
	{
		QuyenSuDungDAO qsdDao = new QuyenSuDungDAO();
		return qsdDao.getCountTotalQSD();
	}
	
	private void setThongKe()
	{
		int ttq = 0,nvl = 0,cbtk = 0;
		int i = 0;
		for(JCheckBox ck : checkBoxs)
		{
			if(i>-1 && i<13)
			{
				if(ck.isSelected())
					ttq++;
			}
			else if(i>12 && i<20)
			{
				if(ck.isSelected())
					nvl++;
			}
			else if(i>19)
			{
				if(ck.isSelected())
					cbtk++;
			}
			i++;
		}
		lblTongQuyenHT.setText(getTongSoQuyenCuaHT()+"");
		lblTKQLTTQ.setText(ttq+"");
		lblTKQLNVL.setText(nvl+"");
		lblTKBCTK.setText(cbtk+"");
		lblTongCong.setText(ttq+nvl+cbtk+"");
	}
	// ========================= END PROCESS METHOD ==================

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getPanelDSTK(), null);
			jContentPane.add(getPanelQuyen(), null);

			jContentPane.add(getPanelThongKe(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes panelDSTK
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelDSTK() {
		if (panelDSTK == null) {
			panelDSTK = new JPanel();
			panelDSTK.setLayout(null);
			panelDSTK.setBounds(new Rectangle(15, 17, 212, 326));
			panelDSTK.setBorder(BorderFactory
					.createTitledBorder("Danh Sách Tài Khoản"));
			panelDSTK.add(getScrollPaneDSTK(), null);
		}
		return panelDSTK;
	}

	/**
	 * This method initializes scrollPaneDSTK
	 * 
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getScrollPaneDSTK() {
		if (scrollPaneDSTK == null) {
			scrollPaneDSTK = new JScrollPane();
			scrollPaneDSTK.setBounds(new Rectangle(9, 25, 195, 292));
			scrollPaneDSTK.setViewportView(getListTK());
		}
		return scrollPaneDSTK;
	}

	/**
	 * This method initializes listTK
	 * 
	 * @return javax.swing.JList
	 */
	private JList getListTK() {
		if (listTK == null) {
			listTK = new JList(getAllTaiKhoan());
			listTK.addListSelectionListener(new ListSelectionListener() {

				@Override
				public void valueChanged(ListSelectionEvent arg0) {
					processSelectItemList();
				}
			});
		}
		return listTK;
	}

	/**
	 * This method initializes panelQuyen
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelQuyen() {
		if (panelQuyen == null) {
			panelQuyen = new JPanel();
			panelQuyen.setLayout(null);
			panelQuyen.setBounds(new Rectangle(239, 18, 535, 475));
			panelQuyen.setBorder(BorderFactory
					.createTitledBorder("Quyền - Chức Năng"));
			panelQuyen.add(getTabbedPane(), null);
		}
		return panelQuyen;
	}

	/**
	 * This method initializes tabbedPane
	 * 
	 * @return javax.swing.JTabbedPane
	 */
	private JTabbedPane getTabbedPane() {
		if (tabbedPane == null) {
			tabbedPane = new JTabbedPane();
			tabbedPane.setBounds(new Rectangle(15, 28, 504, 429));
			tabbedPane.addTab("Thông Tin Chung", null, getPanel1(), null);
			tabbedPane.addTab("Nghiệp Vụ - Hóa Đơn - Nguyên Vật Liệu", null,
					getPanel2(), null);
			tabbedPane.addTab("Báo Cáo - Thống Kê", null, getPanel3(), null);
		}
		return tabbedPane;
	}

	/**
	 * This method initializes panel1
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanel1() {
		if (panel1 == null) {
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(40, 295, 152, 25));
			jLabel2.setText("Phân Quyền");
			jLabel2.setFont(jLabel2.getFont().deriveFont(Font.BOLD));
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(40, 119, 143, 25));
			jLabel1.setText("Quản Lý Nhân Viên");
			jLabel1.setFont(jLabel1.getFont().deriveFont(Font.BOLD));
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(40, 15, 109, 25));
			jLabel.setText(Resources_Duy.TITLE_MENU_THONGTINQUAN);
			jLabel.setFont(jLabel.getFont().deriveFont(Font.BOLD));
			panel1 = new JPanel();
			panel1.setLayout(null);
			panel1.add(getPanelTTQ(), null);
			panel1.add(jLabel, null);
			panel1.add(getPanelNV(), null);
			panel1.add(jLabel1, null);
			panel1.add(getPanelPQ(), null);
			panel1.add(jLabel2, null);
		}
		return panel1;
	}

	/**
	 * This method initializes panel2
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanel2() {
		if (panel2 == null) {
			jLabel6 = new JLabel();
			jLabel6.setBounds(new Rectangle(40, 189, 154, 25));
			jLabel6.setText("Nguyên Vật Liệu");
			jLabel6.setFont(jLabel6.getFont().deriveFont(Font.BOLD));
			jLabel4 = new JLabel();
			jLabel4.setBounds(new Rectangle(40, 119, 146, 25));
			jLabel4.setText("Thực Đơn");
			jLabel4.setFont(jLabel4.getFont().deriveFont(Font.BOLD));
			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(40, 15, 145, 25));
			jLabel3.setText("Nghiệp Vụ");
			jLabel3.setFont(jLabel3.getFont().deriveFont(Font.BOLD));
			panel2 = new JPanel();
			panel2.setLayout(null);
			panel2.add(getPanelNghiepVu(), null);
			panel2.add(jLabel3, null);
			panel2.add(getPanelThucDon(), null);
			panel2.add(jLabel4, null);
			panel2.add(getPanelNVL(), null);
			panel2.add(jLabel6, null);

		}
		return panel2;
	}

	/**
	 * This method initializes panel3
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanel3() {
		if (panel3 == null) {
			jLabel5 = new JLabel();
			jLabel5.setBounds(new Rectangle(40, 15, 119, 25));
			jLabel5.setText("Báo Cáo - Thống Kê");
			jLabel5.setFont(jLabel5.getFont().deriveFont(Font.BOLD));
			panel3 = new JPanel();
			panel3.setLayout(null);
			panel3.add(getPanelBCTK(), null);
			panel3.add(jLabel5, null);
		}
		return panel3;
	}

	/**
	 * This method initializes panelTTQ
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelTTQ() {
		if (panelTTQ == null) {
			panelTTQ = new JPanel();
			panelTTQ.setLayout(null);
			panelTTQ.setBounds(new Rectangle(19, 38, 468, 78));
			Border b = new MatteBorder(3, 0, 0, 0, Color.BLACK);
			panelTTQ.setBorder(b);
			panelTTQ.add(getCheckBoxTT(), null);
			panelTTQ.add(getCheckBoxKV(), null);
			panelTTQ.add(getCheckBoxBan(), null);
			panelTTQ.add(getCheckBoxThietBi(), null);
		}
		return panelTTQ;
	}

	/**
	 * This method initializes checkBoxTT
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTT() {
		if (checkBoxTT == null) {
			checkBoxTT = new JCheckBox();
			checkBoxTT.setBounds(new Rectangle(20, 15, 164, 25));
			checkBoxTT.setText("1 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_THONGTIN);
			checkBoxTT.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTT);
				}
			});
			checkBoxTT.setName("1");
			checkBoxs.add(checkBoxTT);
		}
		return checkBoxTT;
	}

	/**
	 * This method initializes checkBoxKV
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxKV() {
		if (checkBoxKV == null) {
			checkBoxKV = new JCheckBox();
			checkBoxKV.setBounds(new Rectangle(250, 15, 156, 25));
			checkBoxKV.setText("2 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_KHUVUC);
			checkBoxKV.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxKV);
				}
			});
			checkBoxKV.setName("2");
			checkBoxs.add(checkBoxKV);
		}
		return checkBoxKV;
	}

	/**
	 * This method initializes checkBoxBan
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxBan() {
		if (checkBoxBan == null) {
			checkBoxBan = new JCheckBox();
			checkBoxBan.setBounds(new Rectangle(20, 50, 140, 25));
			checkBoxBan.setText("3 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_BAN);
			checkBoxBan.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxBan);
				}
			});
			checkBoxBan.setName("3");
			checkBoxs.add(checkBoxBan);
		}
		return checkBoxBan;
	}

	/**
	 * This method initializes checkBoxThietBi
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxThietBi() {
		if (checkBoxThietBi == null) {
			checkBoxThietBi = new JCheckBox();
			checkBoxThietBi.setBounds(new Rectangle(250, 50, 136, 25));
			checkBoxThietBi.setText("4 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_THIETBI);
			checkBoxThietBi.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxThietBi);
				}
			});
			checkBoxThietBi.setName("4");
			checkBoxs.add(checkBoxThietBi);
		}
		return checkBoxThietBi;
	}

	/**
	 * This method initializes panelNV
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelNV() {
		if (panelNV == null) {
			panelNV = new JPanel();
			panelNV.setLayout(null);
			panelNV.setBounds(new Rectangle(19, 144, 469, 148));
			panelNV.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			panelNV.add(getCheckBoxTTNV(), null);
			panelNV.add(getCheckBoxPhanCong(), null);
			panelNV.add(getCheckBoxBanDKCL(), null);
			panelNV.add(getCheckBoxQLCL(), null);
			panelNV.add(getCheckBoxChamCong(), null);
			panelNV.add(getCheckBoxTinhLuong(), null);
			panelNV.add(getCheckBoxThuongPhat(), null);
		}
		return panelNV;
	}

	/**
	 * This method initializes checkBoxTTNV
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTTNV() {
		if (checkBoxTTNV == null) {
			checkBoxTTNV = new JCheckBox();
			checkBoxTTNV.setBounds(new Rectangle(20, 15, 210, 25));
			checkBoxTTNV.setText("5 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_THONGTINNV);
			checkBoxTTNV.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTTNV);
				}
			});
			checkBoxTTNV.setName("5");
			checkBoxs.add(checkBoxTTNV);
		}
		return checkBoxTTNV;
	}

	/**
	 * This method initializes checkBoxPhanCong
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxPhanCong() {
		if (checkBoxPhanCong == null) {
			checkBoxPhanCong = new JCheckBox();
			checkBoxPhanCong.setBounds(new Rectangle(250, 15, 156, 25));
			checkBoxPhanCong.setText("6 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_PHANCONG);
			checkBoxPhanCong.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxPhanCong);
				}
			});
			checkBoxPhanCong.setName("6");
			checkBoxs.add(checkBoxPhanCong);
		}
		return checkBoxPhanCong;
	}

	/**
	 * This method initializes checkBoxBanDKCL
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxBanDKCL() {
		if (checkBoxBanDKCL == null) {
			checkBoxBanDKCL = new JCheckBox();
			checkBoxBanDKCL.setBounds(new Rectangle(20, 50, 200, 25));
			checkBoxBanDKCL.setText("7 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_DKCL);
			checkBoxBanDKCL.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxBanDKCL);
				}
			});
			checkBoxBanDKCL.setName("7");
			checkBoxs.add(checkBoxBanDKCL);
		}
		return checkBoxBanDKCL;
	}

	/**
	 * This method initializes checkBoxQLCL
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxQLCL() {
		if (checkBoxQLCL == null) {
			checkBoxQLCL = new JCheckBox();
			checkBoxQLCL.setBounds(new Rectangle(250, 50, 136, 25));
			checkBoxQLCL
					.setText("8 - " + Resources_Duy.TITLE_MENU_ITEM_QLCALAM);
			checkBoxQLCL.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxQLCL);
				}
			});
			checkBoxQLCL.setName("8");
			checkBoxs.add(checkBoxQLCL);
		}
		return checkBoxQLCL;
	}

	/**
	 * This method initializes checkBoxChamCong
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxChamCong() {
		if (checkBoxChamCong == null) {
			checkBoxChamCong = new JCheckBox();
			checkBoxChamCong.setBounds(new Rectangle(20, 85, 185, 25));
			checkBoxChamCong.setText("9 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_CHAMCONG);
			checkBoxChamCong.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxChamCong);
				}
			});
			checkBoxChamCong.setName("9");
			checkBoxs.add(checkBoxChamCong);
		}
		return checkBoxChamCong;
	}

	/**
	 * This method initializes checkBoxTinhLuong
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTinhLuong() {
		if (checkBoxTinhLuong == null) {
			checkBoxTinhLuong = new JCheckBox();
			checkBoxTinhLuong.setBounds(new Rectangle(20, 120, 189, 24));
			checkBoxTinhLuong.setText("11 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_TINHLUONG);
			checkBoxTinhLuong.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTinhLuong);
				}
			});
			checkBoxTinhLuong.setName("11");
			checkBoxs.add(checkBoxTinhLuong);
		}
		return checkBoxTinhLuong;
	}

	/**
	 * This method initializes checkBoxThuongPhat
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxThuongPhat() {
		if (checkBoxThuongPhat == null) {
			checkBoxThuongPhat = new JCheckBox();
			checkBoxThuongPhat.setBounds(new Rectangle(250, 85, 182, 25));
			checkBoxThuongPhat.setText("10 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_THUONGPHAT);
			checkBoxThuongPhat.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxThuongPhat);
				}
			});
			checkBoxThuongPhat.setName("10");
			checkBoxs.add(checkBoxThuongPhat);
		}
		return checkBoxThuongPhat;
	}

	/**
	 * This method initializes panelPQ
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelPQ() {
		if (panelPQ == null) {
			panelPQ = new JPanel();
			panelPQ.setLayout(null);
			panelPQ.setBounds(new Rectangle(19, 319, 469, 44));
			panelPQ.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			panelPQ.add(getCheckBoxTTTK(), null);
			panelPQ.add(getCheckBoxCQTK(), null);
		}
		return panelPQ;
	}

	/**
	 * This method initializes checkBoxTTTK
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTTTK() {
		if (checkBoxTTTK == null) {
			checkBoxTTTK = new JCheckBox();
			checkBoxTTTK.setBounds(new Rectangle(20, 15, 219, 25));
			checkBoxTTTK.setText("12 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_THONGTINTK);
			checkBoxTTTK.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTTTK);
				}
			});
			checkBoxTTTK.setName("12");
			checkBoxs.add(checkBoxTTTK);
		}
		return checkBoxTTTK;
	}

	/**
	 * This method initializes checkBoxCQTK
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxCQTK() {
		if (checkBoxCQTK == null) {
			checkBoxCQTK = new JCheckBox();
			checkBoxCQTK.setBounds(new Rectangle(250, 15, 190, 25));
			checkBoxCQTK.setText("13 - Quản Lý Cấp Quyền");
			checkBoxCQTK.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxCQTK);
				}
			});
			checkBoxCQTK.setName("13");
			checkBoxs.add(checkBoxCQTK);
		}
		return checkBoxCQTK;
	}

	/**
	 * This method initializes panelNghiepVu
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelNghiepVu() {
		if (panelNghiepVu == null) {
			panelNghiepVu = new JPanel();
			panelNghiepVu.setLayout(null);
			panelNghiepVu.setBounds(new Rectangle(19, 38, 468, 78));
			panelNghiepVu.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			panelNghiepVu.add(getCheckBoxBanHang(), null);
			panelNghiepVu.add(getCheckBoxTimBan(), null);
			panelNghiepVu.add(getCheckBoxCTKM(), null);
		}
		return panelNghiepVu;
	}

	/**
	 * This method initializes checkBoxBanHang
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxBanHang() {
		if (checkBoxBanHang == null) {
			checkBoxBanHang = new JCheckBox();
			checkBoxBanHang.setBounds(new Rectangle(20, 15, 164, 25));
			checkBoxBanHang.setText("14 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_BANHANG);
			checkBoxBanHang.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxBanHang);
				}
			});
			checkBoxBanHang.setName("14");
			checkBoxs.add(checkBoxBanHang);
		}
		return checkBoxBanHang;
	}

	/**
	 * This method initializes checkBoxTimBan
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTimBan() {
		if (checkBoxTimBan == null) {
			checkBoxTimBan = new JCheckBox();
			checkBoxTimBan.setBounds(new Rectangle(250, 15, 156, 25));
			checkBoxTimBan.setText("15 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_TIMBAN);
			checkBoxTimBan.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTimBan);
				}
			});
			checkBoxTimBan.setName("15");
			checkBoxs.add(checkBoxTimBan);
		}
		return checkBoxTimBan;
	}

	/**
	 * This method initializes checkBoxCTKM
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxCTKM() {
		if (checkBoxCTKM == null) {
			checkBoxCTKM = new JCheckBox();
			checkBoxCTKM.setBounds(new Rectangle(20, 50, 216, 25));
			checkBoxCTKM.setText("16 - Quản Lý Chương Trình KM");
			checkBoxCTKM.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxCTKM);
				}
			});
			checkBoxCTKM.setName("16");
			checkBoxs.add(checkBoxCTKM);
		}
		return checkBoxCTKM;
	}

	/**
	 * This method initializes panelThucDon
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelThucDon() {
		if (panelThucDon == null) {
			panelThucDon = new JPanel();
			panelThucDon.setLayout(null);
			panelThucDon.setBounds(new Rectangle(19, 144, 468, 42));
			panelThucDon.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			panelThucDon.add(getCheckBoxTTTD(), null);
			panelThucDon.add(getCheckBoxPhaChe(), null);
		}
		return panelThucDon;
	}

	/**
	 * This method initializes checkBoxTTTD
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTTTD() {
		if (checkBoxTTTD == null) {
			checkBoxTTTD = new JCheckBox();
			checkBoxTTTD.setBounds(new Rectangle(20, 15, 217, 25));
			checkBoxTTTD.setText("17 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_THONGTINTD);
			checkBoxTTTD.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTTTD);
				}
			});
			checkBoxTTTD.setName("17");
			checkBoxs.add(checkBoxTTTD);
		}
		return checkBoxTTTD;
	}

	/**
	 * This method initializes checkBoxPhaChe
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxPhaChe() {
		if (checkBoxPhaChe == null) {
			checkBoxPhaChe = new JCheckBox();
			checkBoxPhaChe.setBounds(new Rectangle(250, 15, 156, 25));
			checkBoxPhaChe.setText("18 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_PHACHE);
			checkBoxPhaChe.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxPhaChe);
				}
			});
			checkBoxPhaChe.setName("18");
			checkBoxs.add(checkBoxPhaChe);
		}
		return checkBoxPhaChe;
	}

	/**
	 * This method initializes panelBCTK
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelBCTK() {
		if (panelBCTK == null) {
			panelBCTK = new JPanel();
			panelBCTK.setLayout(null);
			panelBCTK.setBounds(new Rectangle(19, 38, 467, 84));
			panelBCTK.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			panelBCTK.add(getCheckBoxChiPhi(), null);
			panelBCTK.add(getCheckBoxSoLuong(), null);
			panelBCTK.add(getCheckBoxDoanhThu(), null);
			panelBCTK.add(getCheckBoxQuyTM(), null);
		}
		return panelBCTK;
	}

	/**
	 * This method initializes checkBoxChiPhi
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxChiPhi() {
		if (checkBoxChiPhi == null) {
			checkBoxChiPhi = new JCheckBox();
			checkBoxChiPhi.setBounds(new Rectangle(20, 15, 227, 25));
			checkBoxChiPhi.setText("21 - Quản Lý BC-TK "
					+ Resources_Duy.TITLE_MENU_ITEM_CHIPHI);
			checkBoxChiPhi.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxChiPhi);
				}
			});
			checkBoxChiPhi.setName("21");
			checkBoxs.add(checkBoxChiPhi);
		}
		return checkBoxChiPhi;
	}

	/**
	 * This method initializes checkBoxSoLuong
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxSoLuong() {
		if (checkBoxSoLuong == null) {
			checkBoxSoLuong = new JCheckBox();
			checkBoxSoLuong.setBounds(new Rectangle(250, 15, 206, 25));
			checkBoxSoLuong.setText("22 - Quản Lý BC-TK "
					+ Resources_Duy.TITLE_MENU_ITEM_SOLUONG);
			checkBoxSoLuong.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxSoLuong);
				}
			});
			checkBoxSoLuong.setName("22");
			checkBoxs.add(checkBoxSoLuong);
		}
		return checkBoxSoLuong;
	}

	/**
	 * This method initializes checkBoxDoanhThu
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxDoanhThu() {
		if (checkBoxDoanhThu == null) {
			checkBoxDoanhThu = new JCheckBox();
			checkBoxDoanhThu.setBounds(new Rectangle(20, 50, 216, 25));
			checkBoxDoanhThu.setText("23 - Quản Lý BC-TK "
					+ Resources_Duy.TITLE_MENU_ITEM_DOANHTHU);
			checkBoxDoanhThu.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxDoanhThu);
				}
			});
			checkBoxDoanhThu.setName("23");
			checkBoxs.add(checkBoxDoanhThu);
		}
		return checkBoxDoanhThu;
	}

	/**
	 * This method initializes checkBoxQuyTM
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxQuyTM() {
		if (checkBoxQuyTM == null) {
			checkBoxQuyTM = new JCheckBox();
			checkBoxQuyTM.setBounds(new Rectangle(250, 50, 210, 25));
			checkBoxQuyTM.setText("24 - Quản Lý BC-TK "
					+ Resources_Duy.TITLE_MENU_ITEM_QUYTIENMAT);
			checkBoxQuyTM.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxQuyTM);
				}
			});
			checkBoxQuyTM.setName("24");
			checkBoxs.add(checkBoxQuyTM);
		}
		return checkBoxQuyTM;
	}

	/**
	 * This method initializes panelNVL
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelNVL() {
		if (panelNVL == null) {
			panelNVL = new JPanel();
			panelNVL.setLayout(null);
			panelNVL.setBounds(new Rectangle(19, 214, 468, 48));
			panelNVL.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			panelNVL.add(getCheckBoxTTNVL(), null);
			panelNVL.add(getCheckBoxKiemKho(), null);
		}
		return panelNVL;
	}

	/**
	 * This method initializes checkBoxTTNVL
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxTTNVL() {
		if (checkBoxTTNVL == null) {
			checkBoxTTNVL = new JCheckBox();
			checkBoxTTNVL.setBounds(new Rectangle(20, 15, 217, 25));
			checkBoxTTNVL.setText("19 - Quản Lý Thông Tin NVL");
			checkBoxTTNVL.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxTTNVL);
				}
			});
			checkBoxTTNVL.setName("19");
			checkBoxs.add(checkBoxTTNVL);
		}
		return checkBoxTTNVL;
	}

	/**
	 * This method initializes checkBoxKiemKho
	 * 
	 * @return javax.swing.JCheckBox
	 */
	private JCheckBox getCheckBoxKiemKho() {
		if (checkBoxKiemKho == null) {
			checkBoxKiemKho = new JCheckBox();
			checkBoxKiemKho.setBounds(new Rectangle(250, 15, 156, 25));
			checkBoxKiemKho.setText("20 - Quản Lý "
					+ Resources_Duy.TITLE_MENU_ITEM_KIEMKHO);
			checkBoxKiemKho.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					processCheckBoxStateChange(checkBoxKiemKho);
				}
			});
			checkBoxKiemKho.setName("20");
			checkBoxs.add(checkBoxKiemKho);
		}
		return checkBoxKiemKho;
	}

	/**
	 * This method initializes panelThongKe	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getPanelThongKe() {
		if (panelThongKe == null) {
			lblTongQuyenHT = new JLabel();
			lblTongQuyenHT.setBounds(new Rectangle(171, 26, 30, 20));
			lblTongQuyenHT.setText("");
			jLabel7 = new JLabel();
			jLabel7.setBounds(new Rectangle(25, 26, 146, 20));
			jLabel7.setText("Tổng số quyền hệ thống : ");
			panelThongKe = new JPanel();
			panelThongKe.setLayout(null);
			panelThongKe.setBorder(BorderFactory.createTitledBorder("Thống Kê"));
			panelThongKe.setBounds(new Rectangle(15, 348, 212, 142));
			panelThongKe.add(jLabel7, null);
			panelThongKe.add(lblTongQuyenHT, null);
			panelThongKe.add(getJPanel(), null);
			panelThongKe.add(getJPanel1(), null);
		}
		return panelThongKe;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			lblTKBCTK = new JLabel();
			lblTKBCTK.setBounds(new Rectangle(136, 37, 28, 20));
			lblTKBCTK.setText("");
			jLabel10 = new JLabel();
			jLabel10.setBounds(new Rectangle(25, 37, 110, 20));
			jLabel10.setText("QL BC-TK :");
			lblTKQLNVL = new JLabel();
			lblTKQLNVL.setBounds(new Rectangle(136, 20, 28, 20));
			lblTKQLNVL.setText("");
			jLabel9 = new JLabel();
			jLabel9.setBounds(new Rectangle(25, 20, 110, 20));
			jLabel9.setText("QL NV-HD-NVL :");
			lblTKQLTTQ = new JLabel();
			lblTKQLTTQ.setBounds(new Rectangle(136, 2, 28, 20));
			lblTKQLTTQ.setText("");
			jLabel8 = new JLabel();
			jLabel8.setBounds(new Rectangle(25, 3, 110, 20));
			jLabel8.setText("QL Thông tin quán :");
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			jPanel.setBounds(new Rectangle(7, 49, 195, 60));
			jPanel.add(jLabel8, null);
			jPanel.add(lblTKQLTTQ, null);
			jPanel.add(jLabel9, null);
			jPanel.add(lblTKQLNVL, null);
			jPanel.add(jLabel10, null);
			jPanel.add(lblTKBCTK, null);
		}
		return jPanel;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			lblTongCong = new JLabel();
			lblTongCong.setBounds(new Rectangle(118, 4, 28, 20));
			lblTongCong.setText("");
			jLabel11 = new JLabel();
			jLabel11.setBounds(new Rectangle(7, 4, 80, 17));
			jLabel11.setText("Tổng cộng : ");
			jPanel1 = new JPanel();
			jPanel1.setLayout(null);
			jPanel1.setBorder(new MatteBorder(3, 0, 0, 0, Color.BLACK));
			jPanel1.setBounds(new Rectangle(25, 109, 158, 22));
			jPanel1.add(jLabel11, null);
			jPanel1.add(lblTongCong, null);
		}
		return jPanel1;
	}

} // @jve:decl-index=0:visual-constraint="10,10"
